﻿/**
 * Licensed under the MIT License
 *
 * Copyright (c) 2010 Alexandre Croiseaux
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */
package marcel.events
{
	import flash.events.Event;
	
	/**
	 * VideoEvent dispatched by the VideoDisplay and the VideoSubtitles classes
	 * @author Alexandre Croiseaux
	 * @see marcel.media.video.VideoDisplay
	 * @see marcel.media.video.VideoSubtitles
	 */
	public final class VideoEvent extends Event
	{
		//--------------------------------------------------------------------------
		//
		//  Public vars
		//
		//--------------------------------------------------------------------------
		/**
		 * An optional value passed depending of the event type
		 */
		public var value:*;
		
		
		//--------------------------------------------------------------------------
		//
		//  Constructor
		//
		//--------------------------------------------------------------------------
		/**
		 * Constructs a new VideoEvent instance
		 * @param	type	type of the event, must be a constant of the VideoEvent class
		 * @param	val	an optional value
		 */
		public function VideoEvent(type:String, val:* = null)
		{
			super(type, false, false);
			value = val;
		}
		
		
		//--------------------------------------------------------------------------
		//
		//  Public methods
		//
		//--------------------------------------------------------------------------
		/**
		 * overriding clone method for event redispatching
		 * @return	a copy of the current event
		 */
		override public function clone():Event
		{
			return new VideoEvent(type, value);
		}
		
		// const
		/**
		* Dispatched when the video starts playing
		* @eventType	onVideoStart
		*/
		static public const START:String = "onVideoStart";
		
		/**
		* Dispatched when the video stops playing
		* @eventType	onVideoStop
		*/
		static public const STOP:String = "onVideoStop";
		
		/**
		* Dispatched when the video seeks to a keyframe
		* @eventType	onVideoSeek
		*/
		static public const SEEK:String = "onVideoSeek";
		
		/**
		* Dispatched when the video is over
		* @eventType	onVideoEnd
		*/
		static public const END:String = "onVideoEnd";
		
		/**
		* Dispatched when the video reaches end and restarts playing from the beginning (see VideoDisplay.loop)
		* @eventType	onVideoLoop
		*/
		static public const LOOP:String = "onVideoLoop";
		
		/**
		* Dispatched when the video size has changed
		* @eventType	onVideoResize
		*/
		static public const RESIZE:String = "onVideoResize";
		
		/**
		* Dispatched when the video starts buffering
		* @eventType	onVideoBuffering
		*/
		static public const BUFFERING:String = "onVideoBuffering";
		
		/**
		* Dispatched when the video resume playing after being paused
		* @eventType	onVideoPlaying
		*/
		static public const PLAYING:String = "onVideoPlaying";
		
		/**
		* Dispatched when the URL of the video file is not found or a security error happened
		* @eventType	onVideoError
		*/
		static public const ERROR:String = "onVideoError";
		
		/**
		* Dispatched when the a video metadata are received
		* @eventType	onVideoMetaData
		*/
		static public const METADATA:String = "onVideoMetaData";
		
		/**
		* Dispatched when the video file is completly loaded
		* @eventType	onVideoLoadComplete
		*/
		static public const LOAD_COMPLETE:String = "onVideoLoadComplete";
		
		/**
		* Dispatched when the a NetStatusEvent is received by the video stream
		* @eventType	onVideoStatus
		*/
		static public const STATUS:String = "onVideoStatus";
		
		/**
		* Dispatched when a cuepoint is found in the video file
		* @eventType	onVideoCuePoint
		*/
		static public const CUE_POINT:String = "onVideoCuePoint";
		
		/**
		* Dispatched when the video subtitles are loaded and ready tu use
		* @eventType	onVideoSubtitlesReady
		*/
		static public const SUBTITLES_READY:String = "onVideoSubtitlesReady";
		
		/**
		* Dispatched when the video file is loading until LOAD_COMPLETE is dispatched
		* @eventType	onVideoLoading
		*/
		static public const LOADING:String = "onVideoLoading";
		
		/**
		* Dispatched once when the video is paused
		* @eventType	onVideoPause
		*/
		static public const PAUSE:String = "onVideoPause";
	}
}